package com.block.sms.service.factory;


import com.block.common.util.ApplicationContextUtil;
import com.block.sms.enums.SmsTypeEnum;
import com.block.sms.service.IQuickLoginService;
import com.block.sms.service.impl.DefaultProcessServiceImpl;
import com.block.sms.service.quick.JiGQuickLoginServiceImpl;

import java.util.HashMap;
import java.util.Map;

public class QuickLoginFactory {

    private static Map<String, Class<? extends IQuickLoginService>> serviceMap = new HashMap<>();
    static {
        serviceMap.put(SmsTypeEnum.JIG.getValue(), JiGQuickLoginServiceImpl.class);
        serviceMap.put(SmsTypeEnum.DEFAULT.getValue(), DefaultProcessServiceImpl.class);
    }

    public static IQuickLoginService getService(String smsType){

        if (serviceMap.containsKey(smsType)){
            Class<? extends IQuickLoginService> aClass = serviceMap.get(smsType);
            return ApplicationContextUtil.getBean(aClass);
        }
        return ApplicationContextUtil.getBean(DefaultProcessServiceImpl.class);
    }


}
